{extend name="adminblue/base" /}
{block name="resources"/}
<style>
.modal-tab tr:first-child{border-bottom:1px solid #ccc;}
.modal-tab td:first-child{line-height: 50px;text-align:right;width: 25%;}
input[type="text"], input[type="password"], input.text, input.password{margin-top:18px;}
.back-color{
	color: #ffffff;
    padding: 3px 5px;
    border-radius: 15px;
    font-size: 12px;
    margin-left: 10px;
}
.color_1{background: darkcyan;}
.color_2{background: goldenrod;}
.color_3{background: darkcyan;}
.color_4{background: green;}
.color_5{background: red;}
.table-div span.right{
	 margin-left: 10px;
}
.btn_bind{
	background: #4F85F1;
    border-radius: 11px;
    color: #ffffff;
    padding: 3px 8px;
    font-size: 12px;
    margin-right: 5px;
}
.btn_bind:hover{
	color: #ffffff;
}
</style>
{/block}
{block name="main"}
<div class="space-10"></div>
<div class="mod-table">
	<div class="table-div">
		<table>
			<tbody>
				<tr><td class="back-f5f5f5">授权信息</td></tr>
				<tr>
					<td>授&nbsp;&nbsp;权&nbsp;码：
					<span class="right">
					{if condition="$result neq ''"}
						{$devolution_code} &nbsp;&nbsp;<a href="javascript:;" target="_blank" onclick="bind()" class="btn_bind">重新绑定</a>
					{else/}
					<a href="javascript:;" target="_blank"  onclick="bind()" class="btn_bind">立即绑定</a>
					<a href="http://www.niushop.com.cn/authorization.html" target="_blank" class="btn_bind">去授权</a>
					{/if}
					</span>
					</td>
				</tr>
				<tr><td>站点URL：<span class="right" style="margin-left: 14px;">{$result['data']['devolution_url']}</span></td></tr>
				<tr><td>授权时间：<span class="right">
				{notempty name="$result['data']['devolution_obj']['devolution_date']"}
		        	{:getTimeStampTurnTimeByYmd($result.data.devolution_obj.devolution_date)}
		        {/notempty}</span></td></tr>
				<tr><td >当前版本：<span class="back-color color_2">{$niu_version}</span></td></tr>
				<tr><td >最新版本：<span class="back-color color_1">V{$latestVersion.data.latest_version}</span></td></tr>
				
				{if condition="$result['code'] eq 0"}
					<tr>
						<td>
						授权版本：<span class="back-color color_3">{$result.data.devolution_version_name}</span>
						{volist name ="result.data.devolution_module" id = "vo"}
							<span class="back-color color_3">{$vo.devolution_momdel_name}</span>
						{/volist}
						</td>
					</tr>
					<tr><td >授权状态：<span class="back-color color_4" >已授权</span>&nbsp;&nbsp;&nbsp;&nbsp;</td></tr>
				{else/}
					<tr><td >授权状态：<span class="back-color color_5" >未授权</span>&nbsp;&nbsp;&nbsp;&nbsp;</td></tr>
				{/if}
			</tbody>
		</table>
	</div>
</div>

<div class="modal fade hide" id="bind_user" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="width:400px;left:56%">

	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
				<h3>云平台绑定</h3>
			</div>
			<div class="modal-body">
				<div class="modal-infp-style" style="height:165px;width:320px;margin:auto;">
					<table class="modal-tab" style="width: 100%;">
						<tr>
							<td colspan="2" style="text-align:left">输入Niushop官方授权码完成绑定
							<a style="float:right;color:#00C0FF;" href="http://www.niushop.com.cn/authorization.html" target="_blank" >授权</a>
							</td>
						</tr>
						<tr>
							<td>授权码：</td>
							<td>
								<input id="authorization_code" type="text" class="input-common"/>
							</td>
						</tr>
					</table>
				</div>
			</div>
			
			<div class="modal-footer">
				<input type="hidden" id="modify_username_hidden" />
				<button class="btn-common" onclick="binding()" id="butSubmit">绑定</button>
			</div>
		</div>
	</div>
</div>
{/block}
{block name="script"}
<script type="text/javascript">
function bind(){
	$("#bind_user").modal("show");
}

function binding(){
	var authorization_code = $("#authorization_code").val();
	if(authorization_code.length == 0){
		showTip("请输入授权码","warning");
		return;
	}
	$.ajax({
		type:'post',
		url : "{:__URL('ADMIN_MAIN/Upgrade/onlineUpdate')}",
		data:{
			'authorization_code':authorization_code,
		},
		success:function(data){
			if(data['code']==0){
				showMessage('success',data['message']);
				$("#bind_user").modal("hide");
				window.location.reload();
			}else{
				showMessage('error',data['message']);
			}
		}
	})
}
</script>
{/block}